<!--
    @name 索赔申请单
    @author xuliwen
    @date 2021-01-25
-->
<template>
  <section>
    <!-- 顶部按钮 -->
    <div class="btns-container">
      <div class="btns-cls">
        <el-button
          v-for="item in formButtons.filter((o) => o.hidden === true)"
          :key="item.comKey"
          @click="item.clickEvent"
        >
          {{ item.text }}
        </el-button>
      </div>
    </div>
    <!-- 基本信息 -->
    <div class="filter-container filter-title">基本信息</div>
    <div class="filter-container filter-params">
      <el-row ref="vailComponentList1">
        <component
          :is="comp.component"
          v-for="comp in tableComponents1.filter((o) => o.isMust === true)"
          :ref="comp.isRequire ? comp.isRequire + comp.compKey : comp.compKey"
          :key="comp.compKey"
          :validrule="comp.validrule"
          :code-field="comp.codeField"
          :text-field="comp.textField"
          :popups-key="comp.compKey"
          :parent-fileds="comp.parentFileds"
          :code="formField[comp.codeField]"
          :disabled="comp.disabled"
          :o-fields="comp.oFields"
          :options="comp.options"
          :custom-obj="comp.customObj"
          :is-require="comp.isRequire"
          :is-mul="comp.isMul"
          :span="comp.span || 8"
          :label-name="comp.labelName"
          :lookuptype="comp.lookuptype"
          :data-to-object="comp.dataToObj"
          :date-options-type="comp.dateOptionsType"
          @changeCode="getComponentCode"
          @focusCode="getFocusCode"
        />
      </el-row>
    </div>
    <!-- 客户车辆信息 -->
    <div class="filter-container filter-title">客户车辆信息</div>
    <div class="filter-container filter-params">
      <el-row ref="vailComponentList1">
        <component
          :is="comp.component"
          v-for="comp in tableComponents2.filter((o) => o.isMust === true)"
          :ref="comp.isRequire ? comp.isRequire + comp.compKey : comp.compKey"
          :key="comp.compKey"
          :validrule="comp.validrule"
          :code-field="comp.codeField"
          :text-field="comp.textField"
          :popups-key="comp.compKey"
          :parent-fileds="comp.parentFileds"
          :code="formField[comp.codeField]"
          :disabled="comp.disabled"
          :o-fields="comp.oFields"
          :options="comp.options"
          :custom-obj="comp.customObj"
          :is-require="comp.isRequire"
          :is-mul="comp.isMul"
          :span="comp.span || 8"
          :label-name="comp.labelName"
          :lookuptype="comp.lookuptype"
          :data-to-object="comp.dataToObj"
          :date-options-type="comp.dateOptionsType"
          @clickEvent="receiveEvent(comp.clickEvent)"
          @changeCode="getComponentCode"
          @focusCode="getFocusCode"
        />
      </el-row>
    </div>
    <!-- 其他信息 -->
    <div class="filter-container filter-title">其他信息</div>
    <el-tabs v-model="activeName" style="background: #ffff">
      <el-tab-pane label="故障信息" name="first">
        <div class="filter-container filter-params">
          <el-row ref="vailComponentList1">
            <component
              :is="comp.component"
              v-for="comp in tableComponents4.filter((o) => o.isMust === true)"
              :ref="
                comp.isRequire ? comp.isRequire + comp.compKey : comp.compKey
              "
              :key="comp.compKey"
              :validrule="comp.validrule"
              :code-field="comp.codeField"
              :text-field="comp.textField"
              :popups-key="comp.compKey"
              :parent-fileds="comp.parentFileds"
              :code="formField[comp.codeField]"
              :disabled="comp.disabled"
              :o-fields="comp.oFields"
              :options="comp.options"
              :custom-obj="comp.customObj"
              :is-require="comp.isRequire"
              :is-mul="comp.isMul"
              :span="comp.span || 8"
              :label-name="comp.labelName"
              :lookuptype="comp.lookuptype"
              :data-to-object="comp.dataToObj"
              :date-options-type="comp.dateOptionsType"
              @changeCode="getComponentCode"
              @focusCode="getFocusCode"
            />
          </el-row>
        </div>
      </el-tab-pane>
      <el-tab-pane label="附件信息" name="second">
        <OneTableTemplate
          ref="table_3_1"
          :dynamic-buttons="tableButtons_4_2"
          :dynamic-table-cols="tableHeader_4_2"
          :is-show-pagination="false"
        />
      </el-tab-pane>
      <el-tab-pane label="索赔项目" name="three">
        <OneTableTemplate
          ref="table_3_2"
          :dynamic-table-cols="tableHeader_4_3"
          :dynamic-is-show-select="true"
          :is-show-pagination="false"
        />
      </el-tab-pane>
      <el-tab-pane label="索赔备件" name="four">
        <OneTableTemplate
          ref="table_3_3"
          :dynamic-table-cols="tableHeader_4_4"
          :dynamic-is-show-select="true"
          :is-show-pagination="false"
        />
      </el-tab-pane>
      <el-tab-pane label="索赔其他项目" name="five">
        <OneTableTemplate
          ref="table_3_4"
          :dynamic-table-cols="tableHeader_4_5"
          :dynamic-is-show-select="true"
          :is-show-pagination="false"
        />
      </el-tab-pane>
      <el-tab-pane label="审核信息" name="six">
        <OneTableTemplate
          ref="table_3_5"
          :dynamic-table-cols="tableHeader_4_6"
          :is-show-pagination="false"
        />
      </el-tab-pane>
    </el-tabs>
  </section>
</template>

<script>
import OneTableTemplate from '@/components/templates/oneTable'
import { oneTableWithViewTemplateMixins } from '@/components/mixins/oneTableWithViewTemplateMixins'
import { formMixins } from '@/components/mixins/formMixins'
import QueryComponent from '@/components/QueryComponent/QueryComponent'
import request from '@/utils/request'
import api from '@/api/se/apiClaimService'
export default {
  name: 'ClaimApplicationForm',
  components: {
    OneTableTemplate,
    QueryComponent
  },
  mixins: [oneTableWithViewTemplateMixins, formMixins],
  data() {
    return {
      activeName: 'first',
      isView: false,
      formButtons: [
        {
          compKey: 'btnKey0',
          type: '',
          size: 'small',
          text: '保存', // 查询
          name: '', // 按钮图标样式
          position: 'right',
          hidden: true,
          clickEvent: () => this.save()
        },
        {
          compKey: 'btnKey1',
          type: '',
          size: 'small',
          text: '提交', // 查询
          name: '', // 按钮图标样式
          position: 'right',
          hidden: true,
          clickEvent: () => this.submitViod('1')
        }
      ],
      tableComponents1: [
        {
          compKey: 'key0',
          labelName: '申请单号：',
          codeField: 'dlrCode',
          isMul: false,
          component: () => import('@/components/org/commonInput'),
          type: 'inputText',
          isMust: true,
          disabled: true
        },
        {
          compKey: 'key1',
          labelName: '门店名称：',
          codeField: 'dlrFullName',
          isMul: false,
          component: () => import('@/components/org/commonInput'),
          type: 'inputText',
          isMust: true,
          disabled: true
        },
        {
          compKey: 'key2',
          labelName: '门店编码：',
          codeField: 'claimCode',
          isMul: false,
          component: () => import('@/components/org/commonInput'),
          type: 'inputText',
          isMust: true,
          disabled: true
        },
        {
          compKey: 'key3',
          labelName: '单据状态：',
          codeField: 'claimStatus',
          isMul: false,
          component: () => import('@/components/org/commonInput'),
          type: 'inputText',
          isMust: true,
          disabled: true
        },
        {
          compKey: 'key4',
          labelName: '保修鉴定员：',
          codeField: 'claimEmpNO',
          isMul: false,
          component: () => import('@/components/org/commonInput'),
          type: 'inputText',
          isMust: true,
          disabled: true
        },
        {
          compKey: 'key5',
          labelName: '联系电话：',
          codeField: 'linkManTel',
          isMul: false,
          component: () => import('@/components/org/commonInput'),
          type: 'inputText',
          isMust: true,
          disabled: true
        },
        {
          compKey: 'key6',
          labelName: '索赔类别',
          codeField: 'claimType',
          textField: 'claimCategoryName',
          customObj: {
            api: api.findClaimCategory,
            defOptionFields: ['claimCategoryCode', 'claimCategoryName']
          },
          component: () => import('@/components/org/commonSelect'),
          type: 'dropdownList',
          isMust: true,
          isRequire: true
        },
        {
          compKey: 'key7',
          labelName: '故障模式：',
          codeField: 'actionCode',
          component: () => import('@/components/org/LookupValue'),
          oFields: 'statusId,statusText',
          options: [
            { statusId: '1', statusText: '文章1' },
            { statusId: '0', statusText: '文章' }
          ],
          type: 'dropdownList',
          isMust: true,
          isRequire: true
        },
        {
          compKey: 'key8',
          labelName: '预计工时费：',
          codeField: 'claimMonth',
          isMul: false,
          component: () => import('@/components/org/commonInput'),
          type: 'inputText',
          isMust: true,
          disabled: true
        },
        {
          compKey: 'key9',
          labelName: '预计备件费：',
          codeField: 'submitDate',
          isMul: false,
          component: () => import('@/components/org/commonInput'),
          type: 'inputText',
          isMust: true,
          disabled: true
        },
        {
          compKey: 'key10',
          labelName: '其他费用：',
          codeField: 'shipAmount',
          isMul: false,
          component: () => import('@/components/org/commonInput'),
          type: 'inputText',
          isMust: true,
          isRequire: true
        },
        {
          compKey: 'key11',
          labelName: '合计金额：',
          codeField: 'compAmount',
          isMul: false,
          component: () => import('@/components/org/commonInput'),
          type: 'inputText',
          isMust: true,
          isRequire: true
        },
        {
          compKey: 'key12',
          labelName: '补偿金额：',
          codeField: 'wiAmount',
          isMul: false,
          component: () => import('@/components/org/commonInput'),
          type: 'inputText',
          isMust: true,
          disabled: true
        },
        {
          compKey: 'key13',
          labelName: '申请报告类型：',
          codeField: 'partAmount',
          isMul: false,
          component: () => import('@/components/org/commonInput'),
          type: 'inputText',
          isMust: true,
          disabled: true
        },
        {
          compKey: 'key14',
          labelName: '超保说明：',
          codeField: 'sumOtherAmount',
          isMul: false,
          component: () => import('@/components/org/commonInput'),
          type: 'inputText',
          isMust: true,
          disabled: true
        }
      ],
      tableComponents2: [
        {
          compKey: 'key0',
          labelName: 'VIN码：',
          codeField: 'repairOrderCode',
          isMul: false,
          component: () => import('@/components/se/sparePartNameCode'),
          type: 'inputText',
          isMust: true
          // disabled: true,
        },
        {
          compKey: 'key1',
          labelName: '车型号：',
          codeField: 'carLicense',
          isMul: false,
          component: () => import('@/components/org/commonInput'),
          type: 'inputText',
          isMust: true,
          disabled: true
        },
        {
          compKey: 'key2',
          labelName: '车系：',
          codeField: 'carConfigCN',
          isMul: false,
          component: () => import('@/components/org/commonInput'),
          type: 'inputText',
          isMust: true,
          disabled: true
        },
        {
          compKey: 'key3',
          labelName: '车型名称：',
          codeField: 'repairDate',
          isMul: false,
          component: () => import('@/components/org/commonInput'),
          type: 'inputText',
          isMust: true,
          disabled: true
        },
        {
          compKey: 'key4',
          labelName: '生产日期：',
          codeField: 'invoiceDate',
          isMul: false,
          component: () => import('@/components/org/datePicker/datePicker.vue'),
          type: 'datePicker',
          isMust: true,
          disabled: true
        },
        {
          compKey: 'key5',
          labelName: '保修开始日期：',
          codeField: 'mileage',
          isMul: false,
          component: () => import('@/components/org/commonInput'),
          type: 'inputText',
          isMust: true,
          disabled: true
        },
        {
          compKey: 'key6',
          labelName: '行驶里程：',
          codeField: 'payMileage',
          isMul: false,
          component: () => import('@/components/org/commonInput'),
          type: 'inputText',
          isMust: true,
          isRequire: true
        },
        {
          compKey: 'key7',
          labelName: '前电机号：',
          codeField: 'payDate',
          isMul: false,
          component: () => import('@/components/org/datePicker/datePicker.vue'),
          type: 'datePicker',
          isMust: true,
          isRequire: true
        },
        {
          compKey: 'key8',
          labelName: '后电机号：',
          codeField: 'preAuthorCode',
          clickEvent: () => this.goClaimApplication(),
          component: () => import('@/components/org/commonInput/indexLink.vue'),
          isMust: true
          // disabled: true,
        },
        {
          compKey: 'key9',
          labelName: '变速器号：',
          codeField: 'VIN',
          isMul: false,
          component: () => import('@/components/org/commonInput'),
          type: 'inputText',
          isMust: true,
          disabled: true
        },
        {
          compKey: 'key11',
          labelName: '增程器号：',
          codeField: 'buyCaruseCodeName',
          isMul: false,
          component: () => import('@/components/org/commonInput'),
          type: 'inputText',
          isMust: true,
          disabled: true
        },
        {
          compKey: 'key12',
          labelName: '电池包编号：',
          codeField: 'produceDate',
          isMul: false,
          component: () => import('@/components/org/datePicker/datePicker.vue'),
          type: 'datePicker',
          isMust: true,
          disabled: true
        },
        {
          compKey: 'key13',
          labelName: '购件日期：',
          codeField: 'engineCode',
          isMul: false,
          component: () => import('@/components/org/commonInput'),
          type: 'inputText',
          isMust: true,
          disabled: true
        },
        {
          compKey: 'key14',
          labelName: '购件里程：',
          codeField: 'engineCode2',
          isMul: false,
          component: () => import('@/components/org/commonInput'),
          type: 'inputText',
          isMust: true,
          disabled: true
        },
        {
          compKey: 'key15',
          labelName: '车主姓名：',
          codeField: 'underpanNO',
          isMul: false,
          component: () => import('@/components/org/commonInput'),
          type: 'inputText',
          isMust: true,
          disabled: true
        },
        {
          compKey: 'key16',
          labelName: '车主电话：',
          codeField: 'ectCode',
          isMul: false,
          component: () => import('@/components/org/commonInput'),
          type: 'inputText',
          isMust: true,
          disabled: true
        },
        {
          compKey: 'key17',
          labelName: '送修人：',
          codeField: 'ectCode',
          isMul: false,
          component: () => import('@/components/org/commonInput'),
          type: 'inputText',
          isMust: true,
          disabled: true
        },
        {
          compKey: 'key18',
          labelName: '送修人电话：',
          codeField: 'ectCode',
          isMul: false,
          component: () => import('@/components/org/commonInput'),
          type: 'inputText',
          isMust: true,
          disabled: true
        },
        {
          compKey: 'key19',
          labelName: '车辆用途：',
          codeField: 'ectCode',
          isMul: false,
          component: () => import('@/components/org/commonInput'),
          type: 'inputText',
          isMust: true,
          disabled: true
        },
        {
          compKey: 'key20',
          labelName: '客户属性：',
          codeField: 'ectCode',
          isMul: false,
          component: () => import('@/components/org/commonInput'),
          type: 'inputText',
          isMust: true,
          disabled: true
        }
      ],
      tableComponents4: [
        {
          compKey: 'key0',
          labelName: '故障类型',
          codeField: 'custType',
          textField: 'custTypeName',
          customObj: {
            api: api.findCustType,
            defOptionFields: ['custType', 'custTypeName']
          },
          component: () => import('@/components/org/commonSelect'),
          type: 'dropdownList',
          isMust: true,
          isRequire: true
        },
        {
          compKey: 'key1',
          labelName: '故障件代码：',
          codeField: 'pfpCode',
          isMul: false,
          component: () => import('@/components/org/commonInput'),
          type: 'inputText',
          isMust: true
          // disabled: true,
        },
        {
          compKey: 'key2',
          labelName: '故障件名称：',
          codeField: 'pfpName',
          isMul: false,
          component: () => import('@/components/org/commonInput'),
          type: 'inputText',
          isMust: true
          // disabled: true,
        },
        {
          compKey: 'key3',
          labelName: '故障日期：',
          codeField: 'faultDate',
          isMul: false,
          component: () => import('@/components/org/datePicker/datePicker.vue'),
          type: 'datePicker',
          isMust: true,
          // disabled: true,
          isRequire: true
        },
        {
          compKey: 'key4',
          labelName: '故障现象码：',
          codeField: 'csCode',
          textField: 'csCtName',
          customObj: {
            api: api.findFaultPhenomenon,
            defOptionFields: ['csCtCode', 'csCtName']
          },
          component: () => import('@/components/org/commonSelect'),
          type: 'dropdownList',
          isMust: true
        },
        // {
        //   compKey: "key5",
        //   labelName: "故障原因码：",
        //   codeField: "saleOrderCode",
        //   isMul: false,
        //   component: () => import('@/components/org/commonInput/searchInput'),
        //   type: "inputText",
        //   isMust: true,
        // },
        {
          compKey: 'key6',
          labelName: '故障部位：',
          codeField: 'faultPartCode',
          textField: 'faultPartName',
          customObj: {
            api: api.findFaultPartName,
            defOptionFields: ['faultPartCode', 'faultPartName']
          },
          component: () => import('@/components/org/commonSelect'),
          type: 'dropdownList',
          isMust: true
        },
        {
          compKey: 'key7',
          labelName: '故障数据：',
          codeField: 'faultDTC',
          isMul: false,
          component: () => import('@/components/org/commonInput'),
          type: 'inputText',
          isMust: true
        },
        {
          compKey: 'key8',
          labelName: '备注：',
          codeField: 'remark',
          isMul: false,
          span: 16,
          component: () => import('@/components/org/commonInput'),
          type: 'inputText',
          isMust: true
        },
        {
          compKey: 'key9',
          labelName: '故障描述：',
          codeField: 'custComplainCS',
          component: () => import('@/components/org/commonInput/textareaInput'),
          type: 'dropdownList',
          isMust: true,
          span: 24
        },
        {
          compKey: 'key10',
          labelName: '诊断过程：',
          codeField: 'detailCheckSynopsis',
          component: () => import('@/components/org/commonInput/textareaInput'),
          type: 'dropdownList',
          isMust: true,
          isRequire: true,
          span: 24
        },
        {
          compKey: 'key11',
          labelName: '故障处理：',
          codeField: 'repairWay',
          component: () => import('@/components/org/commonInput/textareaInput'),
          type: 'dropdownList',
          isMust: true,
          span: 24
        }
      ],

      tableHeader_4_2: [
        {
          prop: 'controlBtn',
          label: '操作', // 操作
          codeField: 'orgName',
          width: null,
          align: 'center',
          isComponent: true,
          comps: [
            {
              compKey: 'propKey0',
              align: 'center',
              labelName: '删除',
              codeField: 'orgName',
              clickEvent: (index) => this.delete(index),
              component: () => import('@/components/org/linkButton')
            }
          ]
        },
        {
          label: '附件名称',
          prop: 'fileName'
        },
        {
          label: '附件路径',
          prop: 'attachmentFilePath',
          hidden: true,
          alwaysHidden: true
        },
        {
          label: '备注+',
          prop: 'fileRemark',
          isComponent: true,
          comps: [
            {
              compKey: 'compKey5' + this.$utils.generateId(),
              codeField: 'fileRemark',
              component: () => import('@/components/org/commonInput'),
              type: 'inputText',
              rowFileds: 'disabled:discardSetName-是'
            }
          ]
        }
      ],
      tableButtons_4_2: [
        {
          compKey: 'btnKey1',
          type: '',
          size: 'small',
          clickEvent: () => this.handFileListChange(),
          name: 'importTemplate',
          position: 'upload',
          text: '附件上传'
        }
      ],
      tableHeader_4_3: [
        {
          label: '工时编码',
          prop: 'wiCode'
        },
        {
          label: '维修内容',
          prop: 'wiName'
        },
        {
          label: '工时数',
          prop: 'wiQTY'
        },
        {
          label: '工时单价',
          prop: 'wiPrice'
        },
        {
          label: '费用合计',
          prop: 'wiTotal'
        },
        {
          label: '索赔系数',
          prop: 'claimWiCoef'
        },
        {
          label: '是否主工时+',
          prop: 'isMain',
          align: 'center',
          isComponent: true,
          comps: [
            {
              compKey: 'compKey5' + this.$utils.generateId(),
              codeField: 'pointPriceNotTax',
              component: () => import('@/components/org/checkBox'),
              // change: (val, comType, row) => this.changeRow(val, comType, row),
              type: 'inputText',
              rowFileds: 'disabled:discardSetName-是'
            }
          ]
        },
        {
          label: '备注',
          prop: 'remark2'
        }
      ],
      tableHeader_4_4: [
        {
          label: '备件编码',
          prop: 'partCode'
        },
        {
          label: '备件名称',
          prop: 'partName'
        },
        {
          label: '数量',
          prop: 'partQTY'
        },
        {
          label: '单价',
          prop: 'partPrice'
        },
        {
          label: '费用合计',
          prop: 'partSum'
        },
        {
          label: '索赔系数',
          prop: 'partClaimWiCoef'
        },
        {
          label: '是否主工时+',
          prop: 'partIsMain',
          align: 'center',
          isComponent: true,
          comps: [
            {
              compKey: 'compKey5' + this.$utils.generateId(),
              codeField: 'pointPriceNotTax',
              component: () => import('@/components/org/checkBox'),
              // change: (val, comType, row) => this.changeRow(val, comType, row),
              type: 'inputText',
              rowFileds: 'disabled:discardSetName-是'
            }
          ]
        },
        {
          label: '备注',
          prop: 'partRemark'
        }
      ],
      tableHeader_4_5: [
        {
          label: '其他项目No',
          prop: 'otherFeeName',
          hidden: true,
          alwaysHidden: true
        },
        {
          label: '其他项目',
          prop: 'otherFeeNO'
        },
        {
          label: '费用',
          prop: 'otherFee'
        },
        {
          label: '备注',
          prop: 'otherRemark'
        }
      ],
      tableHeader_4_6: [
        {
          label: '保修鉴定申诉ID',
          prop: 'appealID',
          hidden: true,
          alwaysHidden: true
        },
        {
          label: '审核状态',
          prop: 'appealStatus'
        },
        {
          label: '审核意见',
          prop: 'auditMemo'
        },
        {
          label: '审核人',
          prop: 'auditUser'
        },
        {
          label: '审核时间',
          prop: 'auditDate'
        },
        {
          label: '维修类别',
          prop: ''
        },
        {
          label: '备注',
          prop: 'auditRemark'
        }
      ],
      formField: {
        dlrCode: '',
        dlrFullName: '',
        claimStatus: '',
        claimEmpNO: '',
        linkManTel: '',
        claimType: '',
        actionCode: '',
        claimMonth: '',
        submitDate: '',
        shipAmount: '',
        compAmount: '',
        wiAmount: '',
        partAmount: '',
        sumOtherAmount: '0',
        sumAmount: '0',
        repairOrderCode: '',
        carLicense: '',
        carConfigCN: '',
        repairDate: '',
        invoiceDate: '',
        mileage: '',
        payMileage: '',
        payDate: '',
        preAuthorCode: '',
        VIN: '',
        buyCaruseCodeName: '',
        produceDate: '',
        engineCode: '',
        engineCode2: '',
        underpanNO: '',
        ectCode: '',
        gender: '',
        phone: '',
        addrPrivince: '',
        addrCity: '',
        addrCounty: '',
        addrStreet: '',
        linkMan: '',
        linkManTels: '',
        custType: '',
        pfpCode: '',
        pfpName: '',
        faultDate: '',
        csCode: '',
        faultDTC: '',
        remark: '',
        custComplainCS: '',
        detailCheckSynopsis: '',
        repairWay: '',
        faultPartCode: '',
        fujianInfo: [],
        claimProject: [],
        claimPart: [],
        claimOtherPart: [],
        claimInfo: [],
        auditInfo: []
      }
    }
  },
  watch: {
    'formField.repairOrderCode': {
      handler(val, old) {
        if (val != '' && val != old) {
          if (this.$route.params && this.$route.params.claimCode) {
            console.log(123)
          } else {
            this.getInfoDispatchOrderNo(val)
          }
        }
      },
      deep: true
    }
  },
  mounted() {
    if (this.$route.params && this.$route.params.claimCode) {
      this.findClaimDetail({ claimCode: this.$route.params.claimCode })
      if (this.$route.params.viewEdit == 'view') {
        this.formButtons[1].hidden = false
        this.formButtons[2].hidden = false
        this.formButtons[3].hidden = false
        this.tableComponents2[0].disabled = true
      }
    }
  },
  methods: {
    // 跳转索赔申请页面
    goClaimApplication() {
      debugger
    },
    // 上传附件
    handFileListChange(file, fileList) {
      this.handleChange(file)
    },

    handleChange(param) {
      const that = this
      const url = '/mp/file/commonUpload/upload.do'
      that
        .$requestUpload(url, param)
        .then((response) => {
          if (response.result === '1') {
            //  路径
            const attachmentFilePath = response.path[0][0].split('|')[1]
            // 文件名
            const fileName = response.path[0][0].split('|')[0]
            const dataParmas = { fileName, attachmentFilePath }
            that.addFilePath(dataParmas)
          }
        })
        .catch((err) => {})
    },
    // 上传附件
    addFilePath(dataParmas) {
      dataParmas.claimID = this.formField.claimID
      request({
        url: api.addFilePath.APIUrl,
        method: 'post',
        data: dataParmas
      }).then((res) => {
        if (res.result == '1') {
          this.$message.success('上传附件成功')
          this.findClaimDetail({ claimCode: this.formField.claimCode }, '1')
        }
      })
    },
    // 删除附件
    delete(index) {
      const rowdata = this.$refs['table_3_1'].list[index]
      request({
        url: api.deleteFile.APIUrl,
        method: 'post',
        data: rowdata
      }).then((res) => {
        if (res.result == '1') {
          this.$message.success('删除成功')
          this.findClaimDetail({ claimCode: this.formField.claimCode }, '1')
        }
      })
    },
    // 查看索赔单
    findClaimDetail(paramD, type) {
      const that = this
      request({
        url: api.findClaimDetail.APIUrl,
        method: 'post',
        data: paramD
      }).then((res) => {
        if (res.result == '1') {
          if (type) {
            this.formField.fujianInfo = res.rows[0].fujianInfo
            this.$refs['table_3_1'].list = this.formField.fujianInfo
          } else {
            this.formField = Object.assign(this.formField, res.rows[0])
            this.$refs['table_3_1'].list = this.formField.fujianInfo
            this.$refs['table_3_2'].list = this.formField.claimProject
            this.$refs['table_3_3'].list = this.formField.claimPart
            this.$refs['table_3_4'].list = this.formField.claimOtherPart
            this.$refs['table_3_5'].list = this.formField.claimInfo
            this.$refs['table_3_7'].list = this.formField.auditInfo
          }
        }
      })
    },
    // 派工单选择
    getInfoDispatchOrderNo(val) {
      request({
        url: api.dispatchOrderNo.APIUrl,
        method: 'post',
        data: { repairOrderCode: val }
      }).then((res) => {
        if (res.result == '1') {
          for (const key in this.formField) {
            if (
              key == 'fujianInfo' ||
                key == 'claimProject' ||
                key == 'claimPart' ||
                key == 'claimOtherPart' ||
                key == 'claimInfo' ||
                key == 'auditInfo'
            ) {
              this.formField[key] = []
            } else if (key != 'repairOrderCode') {
              this.formField[key] = ''
            }
          }
          this.formField = Object.assign(this.formField, res.rows[0])
        }
      })
    },
    // 新增索赔单、索赔单修改
    save() {
      const urlApi = this.$route.params.claimCode
        ? api.updateClaim.APIUrl
        : api.claimantAdd.APIUrl
      request({
        url: urlApi,
        method: 'post',
        data: this.formField
      }).then((res) => {
        if (res.result == '1') {
          this.$message.success(res.msg)
          this.$router.go(-1)
        } else {
          this.$message.warning(res.msg)
        }
      })
    },
    // 索赔单提交、作废、旧件卡打印
    submitViod(type) {
      let urlApi = ''
      if (type == '1') {
        urlApi = api.claimSubmit.APIUrl
      } else if (type == '0') {
        urlApi = api.zfClaimDetail.APIUrl
      } else {
        urlApi = api.printOldCard.APIUrl
      }
      request({
        url: urlApi,
        method: 'post',
        data: { claimID: this.formField.claimID }
      }).then((res) => {
        if (res.result == '1') {
          this.$message.success(res.msg)
          this.$router.go(-1)
        } else {
          this.$message.warning(res.msg)
        }
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.btns-container {
  background-color: #fff;
  overflow: hidden;
  padding-right: 20px;
  .btns-cls {
    float: right;
  }
}
.mainten-table__line {
  width: 100%;
  height: 30px;
  padding: 0 20px;
  line-height: 30px;
  background-color: #fff;
  &-info {
    float: left;
  }
  &-btns {
    float: right;
  }
}
</style>
